<?php

if (!function_exists('camel_case_to_snake_case')) {
    /**
     * @param $input
     * @return string
     * 小驼峰转换为下划线形式
     */
    function camel_case_to_snake_case($input)
    {
        $pattern = '/(?<=[a-z])([A-Z])/';
        $replace = '_$1';

        $snakeCase = strtolower(preg_replace($pattern, $replace, $input));

        return $snakeCase;
    }
}

if (!function_exists('array_to_object')) {
    /**
     * @param $array
     * @return mixed|object
     * 多维数组转为字符串
     */
    function array_to_object($array)
    {
        if (!is_array($array)) {
            return $array;
        }

        foreach ($array as $key => $value) {
            $array[$key] = array_to_object($value);
        }

        return (object)$array;
    }
}